﻿<%@ Page Language="C#" AutoEventWireup="false" Inherits="HeroldIT.Dnn.Modules.CodeBehind.FileBrowser" %>
<%@ Import Namespace="HeroldIT.Dnn.JQuery"%>
<%@ Register assembly="HeroldIT.Dnn.JQuery.Extras" namespace="HeroldIT.Dnn.JQuery.Extras" tagprefix="jqui" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link rel="Stylesheet" href="~/Portals/_default/default.css" type="text/css" />
    <link rel="Stylesheet" href="FileBrowser.css" type="text/css" />
</head>
<body>
    <form id="form" runat="server">
        <asp:ScriptManager runat="server" id="scriptManager" enablepartialrendering="true" />
        <script type="text/javascript">
        function getSelectedFile() {
            return jQuery('#<%= ((Control)this.btnSelectedFile).ClientID %>').text();
        }
        </script>
        <jqui:WindowedDialogChild runat="server" id="wdlgChild" />
        <table class="file-browser">
<%--
            <tr>
                <th class="file-browser-head" colspan="2"><%= HttpUtility.HtmlEncode(this.PageTitle) %></th>
            </tr>
--%>
            <tr class="file-browser-current">
                <td class="file-browser-current-folder"><asp:Label runat="server" id="lblCurrentFolder" /> <asp:UpdatePanel runat="server" id="updCurrentFolder" rendermode="Inline" childrenastriggers="false" updatemode="Conditional"><ContentTemplate><strong><asp:Label runat="server" id="txtCurrentFolder" /></strong></ContentTemplate></asp:UpdatePanel>
                    <asp:UpdateProgress runat="server" displayafter="1000" dynamiclayout="true"><ProgressTemplate><img src="<%= this.ResolveUrl("~/images/dnnanim.gif") %>" alt="..." /></ProgressTemplate></asp:UpdateProgress>
                </td>
                <td class="file-browser-creation">
                    <asp:UpdatePanel runat="server" id="updCreation" childrenastriggers="false" rendermode="Block" updatemode="Conditional">
                        <ContentTemplate>
                            <asp:PlaceHolder runat="server" id="plhCreation">
                                <asp:PlaceHolder runat="server" id="plhCreateFolder" visible="<%# this.ShowFolders %>"><a href="#" onclick="jQuery('#<%= this.pnlCreateFolder.ClientID %>').slideToggle('normal',fixHeight);jQuery('#<%= this.pnlUploadFile.ClientID %>:visible').slideUp();jQuery('#<%= ((Control)this.txtFolderName).ClientID %>').focus();return false"><img src="<%= this.ResolveUrl("images/folder_add_24.png") %>" alt="<%= this.GetString("btnCreateFolder.Text") %>" title="<%= this.GetString("btnCreateFolder.Text") %>" border="0" width="24" height="24" /></a></asp:PlaceHolder> <a href="#" onclick="jQuery('#<%= this.pnlUploadFile.ClientID %>').slideToggle('normal',fixHeight);jQuery('#<%= this.pnlCreateFolder.ClientID %>:visible').slideUp();jQuery('#<%= this.uplNewFile.ClientID %>').focus();return false"><img src="<%= this.ResolveUrl("images/write_add_24.png") %>" alt="<%= this.GetString("btnUploadFile.Text") %>" title="<%= this.GetString("btnUploadFile.Text") %>" border="0" width="24" height="24" /></a>
                                <asp:Panel runat="server" defaultbutton="btnCreateFolder" id="pnlCreateFolder" style="display: none"><asp:RequiredFieldValidator runat="server" id="rfvFolderName" controltovalidate="txtFolderName" display="Dynamic" enableclientscript="true" errormessage='<%# this.GetString("rfvFolderName.ErrorMessage") %>' setfocusonerror="true" text='<%# this.GetString("rfvFolderName.Text") %>' tooltip='<%# this.GetString("rfvFolderName.ToolTip") %>' validationgroup="createFolder" /> <asp:TextBox runat="server" id="txtFolderName" validationgroup="createFolder" /> <asp:Button runat="server" id="btnCreateFolder" text="Create folder" onclick="btnCreateFolder_Click" validationgroup="createFolder" /></asp:Panel>
                                <asp:Panel runat="server" defaultbutton="btnUploadFile" id="pnlUploadFile" style="display: none"><asp:FileUpload runat="server" id="uplNewFile" /> <asp:Button runat="server" id="btnUploadFile" text="Upload file" onclick="btnUploadFile_Click" causesvalidation="false" onclientclick="$unbindUnload()" /><br />
                                    <asp:CheckBox runat="server" id="chkOverwriteExistingFile" checked="false" />
                                </asp:Panel>
                            </asp:PlaceHolder>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr runat="server" id="trMessage" enableviewstate="false" style="display: none">
                <td class="file-browser-message" colspan="2"><asp:UpdatePanel runat="server" id="updMessage" childrenastriggers="false" rendermode="Block" updatemode="Conditional">
                        <ContentTemplate>
                            <asp:Label runat="server" id="lblMessage" cssclass="file-browser-message" />
                        </ContentTemplate>
                    </asp:UpdatePanel></td>
            </tr>
            <tr>
                <td class="file-browser-files" colspan="2">
                    <div id="file-browser-files">
                        <asp:UpdatePanel runat="server" id="updFiles" childrenastriggers="false" rendermode="Block" updatemode="Conditional">
                            <ContentTemplate>
                                <ul>
                                    <asp:Repeater runat="server" id="rptFolders">
                                        <ItemTemplate>
                                            <li>
                                                <div class="file-browser-image"><table><tr><td><asp:LinkButton runat="server" id="btnFolderImage" commandargument="<%# (string) Container.DataItem %>" oncommand="btnFolder_Command"><img src="<%# this.ResolveUrl("images/folder_48.png") %>" alt="<%# HttpUtility.HtmlEncode((string) Container.DataItem) %>" title="<%# HttpUtility.HtmlEncode((string) Container.DataItem) %>" /></asp:LinkButton></td></tr></table></div>
                                                <div class="file-browser-caption"><asp:LinkButton runat="server" id="btnFolderCaption" commandargument="<%# HttpUtility.HtmlEncode((string) Container.DataItem) %>" oncommand="btnFolder_Command"><%# HttpUtility.HtmlEncode((string) Container.DataItem) %></asp:LinkButton></div></li>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                    <asp:Repeater runat="server" id="rptFiles">
                                        <ItemTemplate>
                                            <li <%# this.IsFileSelected((string) Container.DataItem) ? "class=\"selected\"" : "" %>><div class="file-browser-image"><table><tr><td><asp:LinkButton runat="server" id="btnFileImage" commandargument="<%# (string) Container.DataItem %>" oncommand="btnFile_Command"><asp:Image runat="server" id="imgPreview" imageurl="<%# this.GenerateImageUrl((string) Container.DataItem) %>" alternatetext="<%# HttpUtility.HtmlEncode((string) Container.DataItem) %>" tooltip="<%# HttpUtility.HtmlEncode((string) Container.DataItem) %>" /></asp:LinkButton></td></tr></table></div>
                                                <div class="file-browser-caption"><asp:LinkButton runat="server" id="btnFileCaption" commandargument="<%# HttpUtility.HtmlEncode((string) Container.DataItem) %>" oncommand="btnFile_Command"><%# HttpUtility.HtmlEncode((string) Container.DataItem) %></asp:LinkButton></div></li>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </ul>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </td>
            </tr>
            <tr class="file-browser-selected">
                <td><asp:Label runat="server" id="lblSelectedFile" /> <asp:UpdatePanel runat="server" id="updSelectedFile" childrenastriggers="false" rendermode="Inline" updatemode="Conditional"><ContentTemplate><asp:LinkButton runat="server" id="btnSelectedFile" onclick="btnSelectedFile_Click" cssclass="file-browser-selected-file" /></ContentTemplate></asp:UpdatePanel></td>
                <td class="file-browser-buttons"><asp:Button runat="server" id="btnOk" onclientclick="$setDialogResult(getSelectedFile()); return false" usesubmitbehavior="true" /></td>
            </tr>
        </table>
    </form>
<script type="text/javascript">    //<![CDATA[
function fixHeight(){var fbf=jQuery('#file-browser-files');fbf.height(148);fbf.height(fbf.parent().height()-8);/*jQuery('<%= JQuery.JQueryClientID((Control)this.lblCurrentFolder) %>').text(fbf.parent().height()-8);*/}
jQuery(fixHeight);
jQuery(window).resize(fixHeight);
//]]></script>
</body>
</html>
